

            


            
using System;
using System.Collections.Generic;
using System.Web;
namespace DatabaseComponent
{

     

     public partial class OrgnizationChart
     {

         OrgnizationChart _objParent = null;

         public OrgnizationChart objParent
         {
             get {

                 if (ParentID == null)
                 {
                     return new OrgnizationChart();

                 }

                 if (_objParent == null)
                 {
                     OrgnizationChartDB objOrgnizationChartDB = new OrgnizationChartDB(ConnectionStrings.LMS);
                     List<OrgnizationChart> lstOrgnizationChart = objOrgnizationChartDB.getOrgnizationChartByID(ParentID.Value);

                     if (lstOrgnizationChart.Count > 0)
                     {
                         _objParent = lstOrgnizationChart[0];
                     }
                     else
                     {
                         return new OrgnizationChart();
                     }
                 }
                 
                 
                 
                 return _objParent; }
             
         }


         List<OrgnizationChart> _lstChild = null;

         public List<OrgnizationChart> lstChild
         {
             get {

                 if (ChartTypeID == 6)
                 {
                     return new List<OrgnizationChart>();
                 }


                 if (_lstChild == null)
                 {

                     OrgnizationChartDB objOrgnizationChartDB = new OrgnizationChartDB(ConnectionStrings.LMS);
                     List<OrgnizationChart> lstOrgnizationChart = objOrgnizationChartDB.getOrgnizationChartByParentID(ID);

                     if (lstOrgnizationChart.Count == 0)
                     {
                         return new List<OrgnizationChart>();
                     }

                     _lstChild = lstOrgnizationChart;

                 }
                 
                 
                 
                 return _lstChild; }
             
         }



         List<Persons> _lstEmployees = null;

         public List<Persons> lstEmployees
         {
             get {

                 if (_lstEmployees == null)
                 {
                     PersonsDB objPersonsDB = new PersonsDB(ConnectionStrings.LMS);
                     List<Persons> lstPersons = objPersonsDB.getPersonsByOrgChartID(ID);

                     if (lstPersons.Count == 0)
                     {
                         return new List<Persons>();
                     }


                     _lstEmployees = lstPersons;

                 }


                 
                 
                 
                 return _lstEmployees; }
             
         }



         ChartType _objChartType = null;

         public ChartType objChartType
         {
             get {

                 if (_objChartType == null)
                 {
                     ChartTypeDB objChartTypeDB = new ChartTypeDB(ConnectionStrings.LMS);
                     List<ChartType> lstChartType = objChartTypeDB.getChartTypeByID(ChartTypeID);
                     if (lstChartType.Count == 0)
                     {
                         return new ChartType();
                     }


                     _objChartType = lstChartType[0];
                 }
                 
                 
                 
                 
                 
                 return _objChartType; }
            
         }



         
        /// <summary>
        /// this property for checking is this item deleted or not
        /// </summary>
         public bool isDeleted
         {
             
             get
             {
                 if (this.StatusID == 2)
                     return true;





                 OrgnizationChart objCurrent = this;

                 while (objCurrent.objParent.ID != -1)
                 {
                     objCurrent = objCurrent.objParent;
                     if (objCurrent.StatusID == 2)
                         return true;
                 }


                 return false;


             }
         }




         private string _PathEN = "";

         public string PathEN
         {
             get
             {

                 string strRet = "";

                 OrgnizationChart objOrgnizationChart = this;
                 strRet = "/" + objOrgnizationChart.NameEN + strRet;
                 while (objOrgnizationChart.ParentID != null)
                 {
                     objOrgnizationChart = objOrgnizationChart.objParent;

                     strRet = "/" + objOrgnizationChart.NameEN + strRet;

                 }

                 _PathEN = strRet;

                 return _PathEN;
             }

         }


         private string _PathAR = "";

         public string PathAR
         {
             get
             {

                 string strRet = "";

                 OrgnizationChart objOrgnizationChart = this;
                 strRet = "/" + objOrgnizationChart.NameAR + strRet;
                 while (objOrgnizationChart.ParentID != null)
                 {
                     objOrgnizationChart = objOrgnizationChart.objParent;

                     strRet = "/" + objOrgnizationChart.NameAR + strRet;

                 }

                 _PathAR = strRet;

                 return _PathAR;
             }

         }



        


            //Write any additional methods or properties here 
            //Don't modify any genrated classes
     }
}
